package com.own.business.log.operation.persistence.business.service;

import com.own.business.log.operation.persistence.entity.po.LogOperation;
import com.own.business.log.operation.persistence.entity.po.LogOperationElasticPo;
import com.own.business.log.operation.persistence.entity.query.LogOperationQuery;
import com.own.business.log.operation.persistence.entity.query.LogOperationStatsTimeRangeQuery;
import com.own.business.log.operation.persistence.entity.vo.LogOperationElasticVo;
import com.own.component.common.model.ItemCountModel;
import com.own.component.common.model.ItemLongCountModel;
import com.own.component.common.model.entity.ChildrenItemModel;
import com.own.component.elastic.service.BaseElasticService;

import java.util.List;

/**
 * LogOperationElasticService
 *
 * @author chenxueli
 * @date 2023-12-15 11:42:04
 */
public interface LogOperationElasticService extends BaseElasticService<
        LogOperation,
        LogOperationElasticPo,
        LogOperationElasticVo,
        LogOperationQuery
        > {

    /**
     * 根据链路id获取日志信息
     *
     * @param traceId 链路id
     * @return 日志信息
     */
    LogOperationElasticVo getByTraceId(String traceId);

    /**
     * 统计时间范围内的操作次数
     *
     * @param query 查询条件
     * @return 操作次数统计
     */
    List<ChildrenItemModel<ItemCountModel, ItemCountModel>> statsForTimeRange(LogOperationStatsTimeRangeQuery query);

    /**
     * 统计时间范围内的用户id操作次数
     *
     * @param query 查询条件
     * @return 操作次数统计
     */
    List<ChildrenItemModel<ItemCountModel, ItemLongCountModel>> statsForUserTimeRange(LogOperationStatsTimeRangeQuery query);

    /**
     * 统计时间范围内的用户id数量
     *
     * @param query 查询条件
     * @return 用户id数量
     */
    List<ItemCountModel> statsForUserCountTimeRange(LogOperationStatsTimeRangeQuery query);

    /**
     * 统计时间范围内的设备数量
     *
     * @param query 查询条件
     * @return 设备数量
     */
    List<ChildrenItemModel<ItemCountModel, ItemCountModel>> statsForDeviceCountTimeRange(LogOperationStatsTimeRangeQuery query);

}

